
package com.tools.cleanmaster.ui.view.trash;

import android.graphics.drawable.Drawable;
import android.text.TextUtils;

import com.tools.cleanmaster.CleanApplication;
import com.tools.cleanmaster.R;
import com.tools.cleanmaster.appinfo.AppInfoSnapshot;
import com.tools.cleanmaster.model.item.TrashItem;

class AppTrash extends TrashViewItemSingle {
    private final AppInfoSnapshot mAppInfo;

    AppTrash(TrashItem item, AppInfoSnapshot appInfo, TrashGroup group) {
        super(item, group);
        mAppInfo = appInfo;
    }

    @Override
    public Drawable getIcon() {
        Drawable icon = mAppInfo == null ? null : mAppInfo.getIcon();
        if (icon == null) {
            icon = CleanApplication.getInstance().getResources().getDrawable(R.drawable.default_app_icon);
        }
        return icon;
    }

    @Override
    public String getTitle() {
        String title = mAppInfo == null ? null : mAppInfo.getLabel();
        if (TextUtils.isEmpty(title)) {
            title = CleanApplication.getInstance().getResources()
                    .getString(R.string.trash_clean_apk_version_broken);
        }
        return title;
    }

}
